
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class FoodObj extends GameObj {
    Random r=new Random();
    public FoodObj() {
        super();
    }
    public FoodObj(Image img, int x, int y, GameWin frame) {
        super(img, x, y, frame);
    }

    // 生成单个食物（原有方法不变）
    public FoodObj getFood(){
        return new FoodObj(GameUtils.foodImg,r.nextInt(20)*30,(r.nextInt(19)+1)*30,this.frame);
    }

    // 新增：批量生成指定数量的食物
    public List<FoodObj> getFoodList(int count){
        List<FoodObj> foodList = new ArrayList<>();
        for(int i=0;i<count;i++){
            foodList.add(getFood());
        }
        return foodList;
    }

    @Override
    public void paintSelf(Graphics g) {
        super.paintSelf(g);
    }
}